#include "BitFlag.h"


BitFlag::BitFlag()
{
	pointer = 0;
	bitNumber = 0;
}

BitFlag::BitFlag(volatile unsigned char* p, unsigned char number)
{
	pointer = p;
	bitNumber = number;
	
}


BitFlag::BitFlag(unsigned char* p, unsigned char number)
{
	pointer = (volatile unsigned char*) p;
	bitNumber = number;
}
void BitFlag::setBit(unsigned char value) volatile
{
	//Should do an assertion here to check if value is not 1 or 0.
	*pointer = SetBit(*pointer, bitNumber, value);	
}

unsigned char BitFlag::getBit() volatile 
{
	unsigned char* p = (unsigned char*) pointer;
	unsigned char value = GetBit(*p, bitNumber);
	return value;
}


void BitFlag::notBit() volatile 
{
	unsigned char* p = (unsigned char*) pointer;
	unsigned char val = (~(GetBit(*p, bitNumber)) & 0x01);
	*p = SetBit(*p, bitNumber, val); 
}


BitFlag& BitFlag::operator=(const BitFlag& f) volatile
{
	pointer = f.pointer;
	bitNumber = f.bitNumber;
}

